package com.ruoyi.datastatistics.service.impl;

import com.ruoyi.basedata.domain.RealtimegatherdataXbView;
import com.ruoyi.common.utils.DateUtil;
import com.ruoyi.datastatistics.mapper.NotCopiedBackXbMapper;
import com.ruoyi.datastatistics.service.INotCopiedBackXbService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service
public class NotCopiedBackXbServiceImpl implements INotCopiedBackXbService {

    @Autowired
    private NotCopiedBackXbMapper notCopiedBackxbMapper;

    @Override
    public List<RealtimegatherdataXbView> didNotCopyBackToday(RealtimegatherdataXbView realtimegatherdataXb) {
        if (realtimegatherdataXb.getParams().get("beginReadDate") == null || realtimegatherdataXb.getParams().get("endReadDate") == null){
            SimpleDateFormat foramt = new SimpleDateFormat("yyyy-MM-dd");
            realtimegatherdataXb.getParams().put("beginReadDate", DateUtil.past7Days());
            realtimegatherdataXb.getParams().put("endReadDate",foramt.format(new Date()));
        }
        return notCopiedBackxbMapper.didNotCopyBackToday(realtimegatherdataXb);
    }

    @Override
    public List<RealtimegatherdataXbView> historyNotCopyBack(RealtimegatherdataXbView realtimegatherdataXb) {
        if (realtimegatherdataXb.getParams().get("beginReadDate") == null || realtimegatherdataXb.getParams().get("endReadDate") == null){
            SimpleDateFormat foramt = new SimpleDateFormat("yyyy-MM-dd");
            realtimegatherdataXb.getParams().put("beginReadDate", DateUtil.past7Days());
            realtimegatherdataXb.getParams().put("endReadDate",foramt.format(new Date()));
        }
        return notCopiedBackxbMapper.historyNotCopyBack(realtimegatherdataXb);
    }
}
